import { getStore } from '@/util/store'

const dic = {
  eliminateType: [
    { label: '取消物料供货资格', value: '1' },
    { label: '合格供应商降级', value: '2' },
    { label: '加入黑名单', value: '3' }
  ],
  supplierType: [
    {
      label: 'xxx',
      value: '1'
    }
  ],
  supplierDemote: [
    {
      label: '注册',
      value: '0'
    },
    {
      label: '推荐',
      value: '1'
    }
  ],
  demoteReason: [
    {
      label: 'xxx',
      value: '0'
    }
  ],
  isUnpaidOrder: [
    {
      label: '是',
      value: '1'
    },
    {
      label: '否',
      value: '2'
    }
  ]
}

export const option = function () {
  return {
    labelWidth: 120,
    emptyBtn: false,
    submitBtn: false,
    detail: ['view'].includes(this.type),
    column: [
      {
        label: '淘汰申请单号',
        span: 8,
        prop: 'eliminateApplyCode',
        maxlength: 100,
        disabled: true
      },
      {
        label: '申请人',
        span: 8,
        prop: 'applyPerson',
        maxlength: 100,
        disabled: true,
        value: getStore({ name: 'userInfo' }).user_name
      },
      {
        label: '申请日期',
        span: 8,
        prop: 'applyDate',
        type: 'date',
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dd',
        maxlength: 100,
        disabled: true,
        value: new Date()
      },
      {
        label: '供应商名称',
        prop: 'supplierName',
        formslot: true,
        span: 8,
        rules: [
          {
            required: true,
            message: '请选择供应商名称',
            trigger: 'change'
          }
        ]
      },
      {
        label: '供应商编码',
        span: 8,
        prop: 'supplierCode',
        disabled: true
      },
      {
        label: '供应商身份',
        span: 8,
        prop: 'supplierIdentity',
        disabled: true
      },
      {
        label: '淘汰类型',
        prop: 'eliminateType',
        clearable: false,
        type: 'select',
        props: {
          label: 'label',
          value: 'value'
        },
        dicData: dic.eliminateType,
        span: 8,
        value: '1',
        rules: [
          {
            required: true,
            message: '请选择淘汰类型',
            trigger: 'change'
          }
        ],
        control: (val, form) => {
          if (val === '1') {
            return {
              eliminateCategory: {
                display: true
              },
              materialClassify: {
                display: true
              },
              eliminateReason: {
                display: true
              },
              blacklistDate: {
                display: false
              },
              supplierDemote: {
                display: false
              },
              demoteReason: {
                display: false
              }
            }
          }
          if (val === '2') {
            return {
              eliminateCategory: {
                display: false
              },
              blacklistDate: {
                display: false
              },
              supplierDemote: {
                display: true
              },
              materialClassify: {
                display: false
              },
              eliminateReason: {
                display: false
              },
              demoteReason: {
                display: true
              }
            }
          }
          if (val === '3') {
            return {
              eliminateCategory: {
                display: false
              },
              blacklistDate: {
                display: true
              },
              supplierDemote: {
                display: false
              },
              materialClassify: {
                display: false
              },
              eliminateReason: {
                display: true
              },
              demoteReason: {
                display: false
              }
            }
          }
        }
      },
      {
        label: '淘汰物料分类',
        prop: 'eliminateCategory',
        formslot: true,
        display: true,
        span: 8,
        rules: [
          {
            required: true,
            message: '请选择淘汰物料分类',
            trigger: 'change'
          }
        ]
      },
      {
        label: '黑名单截止日期',
        prop: 'blacklistDate',
        type: 'date',
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dd',
        span: 8,
        display: true
      },
      {
        label: '供应商降级至',
        prop: 'supplierDemote',
        type: 'select',
        props: {
          label: 'label',
          value: 'value'
        },
        dicData: dic.supplierDemote,
        display: true,
        span: 8,
        rules: [
          {
            required: true,
            message: '请选择供应商降级至',
            trigger: 'change'
          }
        ]
      },
      {
        label: '物料品类',
        prop: 'materialClassify',
        formslot: true,
        display: true,
        disabled: true,
        span: 8
      },
      {
        label: '供应商类型',
        prop: 'supplierType',
        disabled: true,
        span: 8
      },
      {
        label: '降级原因',
        prop: 'demoteReason',
        type: 'select',
        props: {
          label: 'label',
          value: 'value'
        },
        dicData: dic.demoteReason,
        display: true,
        span: 8,
        rules: [
          {
            required: true,
            message: '请选择降级原因',
            trigger: 'change'
          }
        ]
      },
      {
        label: '淘汰原因',
        prop: 'eliminateReason',
        type: 'select',
        props: {
          label: 'label',
          value: 'value'
        },
        dicData: dic.supplierType,
        display: true,
        span: 8,
        rules: [
          {
            required: true,
            message: '请选择淘汰原因',
            trigger: 'change'
          }
        ]
      },
      {
        label: '负责人',
        prop: 'leadingCadre',
        formslot: true,
        span: 8
      },
      {
        label: '替换方案说明',
        prop: 'caseRemark',
        type: 'textarea',
        placeholder: '',
        maxlength: 500,
        minRows: 4,
        maxRows: 6,
        span: 24,
        rules: [
          {
            required: true,
            message: '请输入替换方案说明',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '备注',
        prop: 'remark',
        type: 'textarea',
        placeholder: '',
        maxlength: 500,
        minRows: 4,
        maxRows: 6,
        span: 24
      }
    ]
  }
}

export const statusOption = function () {
  return {
    labelWidth: 180,
    emptyBtn: false,
    submitBtn: false,
    detail: ['view'].includes(this.type),
    column: [
      {
        label: '是否有未交货订单',
        prop: 'isUndeliveredOrder',
        span: 8,
        disabled: true
      },
      {
        label: '是否有已交货未付款订单',
        prop: 'isUnpaidOrder',
        span: 8,
        disabled: true
      },
      {
        label: '是否有已交货未付款订单',
        prop: 'isUnpaidOrder',
        span: 8,
        type: 'select',
        props: {
          label: 'label',
          value: 'value'
        },
        dicData: dic.isUnpaidOrder
      }
    ]
  }
}

export const supplierOption = [
  { label: '选择', prop: 'radio', width: 50 },
  { label: '供应商编码', prop: 'supplierCode' },
  { label: '供应商名称', prop: 'supplierName' },
  { label: '供应商类型', prop: 'supplierType' },
  { label: '供应商身份', prop: 'supplierIdentity' }
]
